﻿using Bridge.Shared.Models;
using Microsoft.AspNetCore.Mvc;
using Org.BouncyCastle.Crypto;
using Roles;
using SysConfigs;
using SysConfigs.Input;
using SysConfigs.Output;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;

namespace Bridge.System.HttpApi
{
    [Route("[controller]/[action]")]
    public class SysConfigController : AbpController
    {
        private readonly ISysConfigService _sysConfigService;
        public SysConfigController(ISysConfigService sysConfigService)
        {
            _sysConfigService = sysConfigService;
        }
        [HttpPost]
        public async Task<PageResponseResult<SysConfigOutput>> GetPageListAsync([FromBody]SysConfigPageInput input)
        {
            try
            {
                return await _sysConfigService.GetPageListAsync(input);
            }
            catch (Exception ex)
            {
                return PageResponseResult<SysConfigOutput>.Fail(ex.Message);
            }
        }
        [HttpPost]
        public async Task<ResponseResult<SysConfigOutput>> CreateSysConfig([FromBody] SysConfigInput input)
        {
            try
            {
                return await _sysConfigService.CreateSysConfig(input);
            }
            catch (Exception ex)
            {
                return ResponseResult<SysConfigOutput>.Fail(ex.Message);
            }
        }
        [HttpPost]
        public async Task<ResponseResult> DeleteAsync([FromBody] IdsInput<Guid> ids)
        {
            try
            {
                return await _sysConfigService.DeleteAsync(ids);
            }
            catch (Exception ex)
            {
                return ResponseResult.Fail(ex.Message);
            }
        }
        [HttpGet]
        public async Task<ResponseResult<SysConfigOutput>> GetSysConfigById(Guid Id)
        {
            try
            {
                return await _sysConfigService.GetSysConfigById(Id);
            }
            catch (Exception ex)
            {
                return ResponseResult<SysConfigOutput>.Fail(ex.Message);
            }
        }
        [HttpPost]
        public async Task<ResponseResult> UpdateAsync([FromBody] UpdateSysConfigInput input)
        {
            try
            {
                return await _sysConfigService.UpdateAsync(input);
            }
            catch (Exception ex)
            {
                return ResponseResult.Fail(ex.Message);
            }
        }
    }
}
